<?php
use yii\db\Migration;

class m151120_071753_mobile_verify extends Migration
{
    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }
        
        $this->createTable('{{%mobile_verify}}', [
            'id' => $this->primaryKey(),
            'mobile' => $this->string(20)
                ->notNull(),
            'type' => $this->smallInteger(4)
                ->defaultValue(0), // 1 注册 2 密码修改
            'verify_code' => $this->string(50),
            'created_at' => $this->integer()
        ], $tableOptions);
    }

    public function safeDown()
    {
        $this->dropTable('{{%mobile_verify}}');
    }
}
